package com.cbs.zxing.test;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.cbs.application.activity.CBSActivity;
import com.cbs.ui.qrcodescan.OnCapturedListener;
import com.cbs.ui.qrcodescan.QRCodeScanner;
import com.cbs.ui.toast.Toast;

public class MyActivity extends CBSActivity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Toast.init(this);

        findViewById(R.id.gen).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MyActivity.this, GenActivity.class);
                startActivity(intent);
            }
        });

        findViewById(R.id.scan).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                QRCodeScanner.scan(MyActivity.this, new OnCapturedListener() {
                    @Override
                    public void onSuccess(String result) {
                        Toast.show(result);
                    }

                    @Override
                    public void onFailure(String message) {
                        Toast.show(message);
                    }
                });
            }
        });
    }
}
